package com.itheima.mapper;

import com.itheima.pojo.Brand;
import com.itheima.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BrandMapper {

    /**
     * 查询所有数据
     *
     * @return
     */
    @Select("select * from tb_brand")
    List<Brand> selectAll();

    /**
     * 添加数据
     *
     * @param brand
     */
    @Insert("insert into tb_brand values(null ,#{brandName},#{companyName},#{ordered},#{description},#{status})")
    void add(Brand brand);

    /**
     * 修改数据
     *
     * @return
     */
    @Update("update tb_brand set brand_name=#{brandName},company_name=#{companyName},ordered=#{ordered},description=#{description},status=#{status} where id=#{id}")
    @ResultMap("brandResultMap")
    void updateInformation(Brand brand);

    /**
     * 根据id查找数据
     *
     * @param id
     * @return
     */
    @Select("select * from tb_brand where id=#{id}")
    @ResultMap("brandResultMap")
    Brand selectId(int id);

    /**
     * 根据id删除数据
     *
     * @param id
     */
    @Delete("delete from tb_brand where id=#{id}")
    void delete(int id);

    /**
     * 查询用户名与密码
     * @param username
     * @param password
     * @return
     */
    @Select("select * from tb_user where username=#{username} and password=#{password}")
    User selectUser(@Param("username") String username,@Param("password") String password);
}
